<template>
    <div class="alerts">
        <el-header :title="'头条'"></el-header>
        <div class="inps">
            昵称: <input type="text" placeholder="请输入昵称" v-model="obj.nicename">
            <br>
            标题: <input type="text" placeholder="请输入标题" v-model="obj.title">
            <br>
            内容: <input type="text" placeholder="请输入内容" v-model="obj.content">
            <br>
            <button @click="publicd">添加</button>
        </div>
    </div>
</template>
<script>
import elHeader from './el-header'

export default {
    components:{
        elHeader
    },
    data(){
        return {
            obj:{
                nicename:"",
                title:"",
                content:""
            }
        }
    },
    methods:{
        publicd(){
            this.$http.post('/api/add',this.obj).then((res) => {
                console.log(res)
                if(res.data.code == 1){
                    console.log(this)
                    this.$emit('hidee')
                }
            }).catch((err) => {
                console.log(err)
            })
        }
    }
}
</script>
<style>
.alerts{
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0,0,0,.5)
}
.inps{
    width: 100%;
    height: 100%;
    background: #ffb1b1;
    text-align: center;
    line-height: 40px;
}
</style>
